package tests;


import static org.junit.Assert.*;

import main.Roles;
import main.User;

import org.junit.Before;
import org.junit.Test;

/**
 * Tests the User Class
 * @author Holly Beach
 * Cristopher updated to match new constructor, changed some tests. removed calls
 * to addRole(author) because of added business rule
 * @version 12/3/11
 */
public class UserTest {

	
	User user1;
	
	@Before
	public void setUp() throws Exception {
		user1 = new User("abc@gmail.com", "Joe Smith");
	}
	
	@Test
	public void testConstructor(){
		assertEquals("Is ID correct?", "abc@gmail.com", user1.getID());
		assertEquals("Is Name correct?", "Joe Smith", user1.getName());
		assertEquals("Is roles list correct size?", 1, user1.getRoles().size());
		assertEquals("Does roles list contain correct role?", Roles.AUTHOR,
				user1.getRoles().get(0));
	}

	@Test
	public void testAddRole(){
		user1.addRole(Roles.REVIEWER);
		assertTrue("Was REVIEWER added to list?", user1.getRoles().contains(Roles.REVIEWER));
		assertEquals("Did the size of the roles list increase", 2, user1.getRoles().size());
		user1.addRole(Roles.REVIEWER);
		assertEquals("Duplicate handled correcly?", 2, user1.getRoles().size());
	}
}
